﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Manage_NoteUpdate : System.Web.UI.Page
{
    public string strName1, strContent1;
    public string Notid;

    protected void Page_Load(object sender, EventArgs e)
    {
        Notid = Request.QueryString["Notid"].ToString();
        string strName, strContent;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (!IsPostBack)
            {
                string strSql;
                if (Request.QueryString["Notid"] != null)
                    Notid = Request.QueryString["Notid"].ToString();
                else
                    return;
                strSql = "select * from Note where Notid=" + Notid;
                Db DbInfo = new Db();
                System.Data.IDataReader dr;
                dr = DbInfo.DataReader(strSql);
                if (dr.Read())
                {
                    txtAccountId.Text = dr["AccountId"].ToString();
                    txtAccountId.Visible = false;
                    txtAddDate.Text = Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                    txtInfoId.Text = dr["Notid"].ToString();
                    txtInfoId.Visible = false;
                    strName1 = dr["Title"].ToString();
                    strContent1 = dr["Content"].ToString();

                }
                dr.Close();
                dr.Dispose();
                DbInfo.Close();
            }
            strName = SysFun.ToTrim(Request.Form["txtName"]);
            strContent = SysFun.ToTrim(Request.Form["txtContentHtml"]);
            if (strName != "" && strContent != "")
            {
                Db db = new Db();
                Grove.ORM.ObjectOperator oo = db.GetObjectOperator();
                HZ.MBSM.Model.Note Note = new HZ.MBSM.Model.Note();
                Note.Title = strName;
                Note.Content = strContent.Replace("\r\n", "");
                Note.AccountId = Convert.ToInt64(txtAccountId.Text);
                Note.AddDate = Convert.ToDateTime(txtAddDate.Text);
                Note.DownLoad = "";
                Note.Notid = Convert.ToInt64(Notid);
                oo.Update(Note);
                oo.Dispose();
                db.Close();
                Response.Write("<script>alert('保存成功！！！');</script>");
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "Note", Note.Title + "|" + Note.Content + "|" + Note.AddDate, "../Magage/NoteUpdate.aspx");

                Response.Write("<script>window.opener.location.reload();window.close();</script>");
            }
        }
    }
}
